<fieldset>

	<div class="products view">
		<div id="view">
			<h2><?php echo __('Product'); ?></h2>
			<br />

			<table class="inlineTable" width="20%">
				<tr>
					<td class="heading"><?php echo __('Suppliers'); ?></td>
					<td class="data"><?php echo h($product['Suppliers']['supplierName']); ?>&nbsp;</td>
				</tr>
				<tr>
					<td class="heading"><?php echo __('Brand'); ?></td>
					<td class="data"><?php echo h($product['Productsbrand']['name']); ?>&nbsp;</td>
				</tr>     
				<tr>
					<td class="heading"><?php echo __('Range'); ?></td>
					<td class="data"><?php echo h($product['Productsrange']['name']); ?>&nbsp;</td>
				</tr>
				<tr>
					<td class="heading"><?php echo __('Category'); ?></td>
					<td class="data"><?php echo h($product['Productscategory']['name']); ?>&nbsp;</td>
				</tr>                
			</table>

			<table class="inlineTable" width="20%">
				<tr>
					<td class="heading"><?php echo __('Item'); ?></td>
					<td class="data"><?php echo h($product['Product']['description']); ?>&nbsp;</td>
				</tr>
				<tr>
					<td class="heading"><?php echo __('Size'); ?></td>
					<td class="data"><?php echo h($product['Product']['size']); ?>&nbsp;</td>
				</tr>
				<tr>
					<td class="heading"><?php echo __('Cost Price'); ?></td>
					<td class="data"><?php echo h($product['Product']['cost_price']); ?>&nbsp;</td>
				</tr>
				<tr>
					<td class="heading"><?php echo __('Retail Price'); ?></td>
					<td class="data"><?php echo h($product['Product']['retail_price']); ?>&nbsp;</td>
				</tr>
			</table>
			<table class="inlineTable" width="15%">
				<tr>
					<td class="heading"><?php echo __('Min Level'); ?></td>
					<td class="data"><?php echo h($product['Product']['min_level']); ?>&nbsp;</td>
				</tr>

				<tr>
					<td class="heading"><?php echo __('Max Level'); ?></td>
					<td class="data"><?php echo h($product['Product']['max_level']); ?>&nbsp;</td>
				</tr>

				<tr>
					<td class="heading"><?php echo __('Onhand Level'); ?></td>
					<td class="data"><?php echo h($product['Product']['onhand_level']); ?>&nbsp;</td>
				</tr>
				<tr>
					<td class="heading"><?php echo __('Barcode'); ?></td>
					<td class="data"><?php echo h($product['Product']['barcode']); ?>&nbsp;</td>
				</tr>

			</table>
		</div>
	</div> 
	<br><br>
	<div class="newbutton">
		<ul>
			<li><?php echo $this->Html->link(__('Edit Details'), array('action' => 'edit', $product['Product']['id'])); ?></li>
			<li><?php echo $this->Form->postLink(__('Archive'), array('action' => 'delete', $product['Product']['id']), null, __('Are you sure you want to archive product, %s %s %s %s ?', $product['Productsbrand']['name'],$product['Productsrange']['name'],$product['Productscategory']['name'],$product['Product']['description'])); ?></li>
			<li><?php echo $this->Html->link(__('Back'), array('action' => 'index')); ?></li>
		</ul>
	</div>
	<br><br>


	<!doctype html>

	<script src ="app/webroot/js/bootstrap/bootstrap.js"></script>
	<script>
		$('#myTab a').click(function (e) {
			e.preventDefault()
			$(this).tab('show')

		})
	</script>

	<ul class="nav nav-tabs" id="myTab">
		<li class="active"><a href="#tab-1" data-toggle="tab">Product Used</a></li>
		<li><a href="#tab-2" data-toggle="tab">Orders</a></li>
	</ul>


	<div class="tab-content">
		<div class="tab-pane active" id="tab-1">
			<?php if (!empty($product['Productsinstance'])){?> 
			<table class="table" cellpadding = "0" cellspacing = "0" width="60%"> 
				<tr> 
					<th>Date of Removal</th> 
					<th>Number Removed</th>
					<th>Reason for Removal</th>
				</tr>
				<?php 
				foreach ($product['Productsinstance'] as $productsinstance): ?> 
				<tr> 
					<td><?php echo $productsinstance['doc'];?></td> 
					<td><?php echo $productsinstance['number_removed'];?></td> 
					<td><?php echo $productsinstance['removalReasons_id'];?></td> 
				</tr> 
			<?php endforeach; ?> 
		</table> 
		<?php } else { echo 'No products used recorded for this product.'; } ?> 
	</div> 


	<div class="tab-pane" id="tab-2">
		<?php if (!empty($product['Orders'])){?> 
		<table class="table" cellpadding = "0" cellspacing = "0" width="60%"> 
			<tr> 
				<th>Order Id</th>
				<th>Date</th>
				<th>Amount Ordered</th> 
				<th>Amount Delivered</th>
				<th><?php echo __('Actions');?></th> 
			</tr>
			<?php 
			foreach ($product['Orders'] as $ordersproducts): ?> 
			<tr> 
				<td><?php echo $ordersproducts['Ordersproduct']['orders_id'];?></td>
				<td><?php echo $ordersproducts['created'];?></td>
				<td><?php echo $ordersproducts['Ordersproduct']['orderQty'];?></td> 
				<td><?php echo $ordersproducts['Ordersproduct']['deliveredQty'];?></td> 

				<td class="actions"> 
					<?php echo $this->Html->link(__('View'), array('controller' => 'Orders', 'action' => 'view', $ordersproducts['id'])); ?> 
					<?php echo $this->Html->link(__('Generate PDF'), array('controller' => 'Orders', 'action' => 'viewPdf', $ordersproducts['id'])); ?> 
				</td> 
			</tr> 
			<?php endforeach; ?> 
		</table> 
	<?php } else{ echo 'No orders has been created from this product.';} ?> 
	</div> 
</div>

</fieldset>